<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:text name="header.title"/></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%> 
</head>
<s:set name="siteId" value="#session['CURRENT_SITE'].siteId"></s:set>
<body id="bodyleft">
<div class="leftwrapper">
<div id="menuclass" class="menushow fl">
	<dl>
		<dt>&nbsp;</dt>
		<s:if test="%{authLicence('1_1_5')||authLicenceLike('2_2_1')}">
		<dd id="li1">站点</dd>
		</s:if>
		<s:if test="#session['CURRENT_SITE']!=null">
		
		<s:if test="%{authLicenceLikeSite('3_3_1,3_3_2,2_2_2')}">
		<dd id="li2">栏目</dd>
		</s:if>
		<s:if test="%{authLicenceLikeSite('3_3_2,3_3_3,3_3_4,3_3_5,3_3_6')}">
		<dd id="li3">内容</dd>
		</s:if>
		<s:if test="%{authLicenceLikeSite('2_2_3,4_4_1,4_4_2,4_4_3,4_4_4,4_4_5,4_4_6')}">
		<dd id="li4">专题</dd>
		</s:if>
		</s:if>
		<s:if test="%{authLicence('1_1_6')}">
		<dd id="li5">主题</dd>
		</s:if>
		<s:if test="#session['CURRENT_SITE']!=null">
		<s:if test="%{authLicenceLikeSite('2_2_6,3_3_2,4_4_2')}">
		<dd id="li6">发布</dd>
		</s:if>
		<s:if test="%{authLicenceLikeSite('2_2_4,2_2_5')}">
		<dd id="li7">插件</dd>
		</s:if>
		</s:if>
		<s:if test="%{authLicenceLikeSite('1_1_1,1_1_2,1_1_3,1_1_4,1_1_5,1_1_6,1_1_7,1_1_8')}">
		<dd id="li8">系统</dd>
		</s:if>
		<dd id="li10" class="current">首页</dd>
	</dl>
</div>
<div id="leftmenu" class="leftmenu fl" style="display:none;">
	<dl id="li1_dl">
		<dt>&nbsp;<span class="sitetit">站点管理</span>
		<s:if test="%{authLicence('1_1_5')}">
			<a href="${ctx}/site/site-input.action" class="createsite" target='mainframe'>&nbsp;</a>
		</s:if> 
		</dt>
		<div id="sitemanager">
		</div>
	</dl>
	<dl id="li2_dl">
		<dt>栏目管理</dt>
		<div  id="treeDiv_Cat" class="canremove" >
			<div id="ztree_cat" class="ztree" ></div>
		</div> 
	</dl>
	<dl id="li3_dl">
		<dt>内容管理</dt>
		<div id="treeDiv_Content" class="canremove">
			<div id="ztree_content" class="ztree" ></div>
		</div>
	</dl>
	<dl id="li4_dl">
		<dt>专题管理</dt>
		<dd class="current" >
			<s:if test="%{authLicenceLikeSite('2_2_3,4_4_1,4_4_2,4_4_3,4_4_4,4_4_5,4_4_6')}">
				<a href="${ctx}/topic/topic-list.action" target='mainframe'>专题列表</a>
			</s:if> 
		</dd>
	</dl>
	<dl id="li5_dl">
		<dt>模版管理</dt>
		<s:if test="%{authLicence('1_1_6')}">
		<dd class="current"><a href="${ctx}/theme/theme-list.action" target='mainframe'>主题管理</a></dd>
		<dd ><a href="${ctx}/theme/file-manage.action" target='mainframe'>主题文件管理</a></dd>
		</s:if> 
	</dl>
	<dl id="li6_dl">
		<dt>发布管理</dt>
		<dd><a id="<s:property value="#session.CURRENT_SITE.siteId"/>" href="${ctx}/generate/list-site.action?site.siteId=<s:property value="#session.CURRENT_SITE.siteId"/>" target='mainframe'><s:property value="#session.CURRENT_SITE.siteName"/> </a></dd>
	</dl>
	<dl id="li7_dl">
		<dt>插件管理</dt>
		<s:if test="%{authLicence('2_2_4',#siteId)}">
			<dd class="current"><a href="${ctx}/plugins/survey-list.action" target='mainframe' class='ico_1'>调查</a></dd>
		</s:if> 
		<s:if test="%{authLicence('2_2_5',#siteId)}">
			<dd ><a href="${ctx}/plugins/vote-list.action" target='mainframe' class='ico_2'>投票</a></dd>
		</s:if> 
	</dl>
	<dl id="li8_dl">
		<dt>系统管理<span>&nbsp;</span></dt>
			<s:if test="%{authLicence('1_1_3')}">
				<dd class="current"><a href="${ctx}/system/role-list.action" target="mainframe">角色管理</a>	</dd>
			</s:if> 
			<s:if test="%{authLicence('1_1_2')}">
				<dd ><a href="${ctx}/system/admin-list.action"  target="mainframe">管理员管理</a>	</dd>
			</s:if>
			<s:if test="%{authLicence('1_1_1')}">
				<dd ><a href="${ctx}/system/config-list.action?configType=sys_User_Config"  target="mainframe">系统配置</a></dd>
			</s:if>
			<s:if test="%{authLicence('1_1_4')}">
				<dd><a href="${ctx}/system/operlog-list.action" target="mainframe">监控日志</a></dd>
			</s:if>	
			<s:if test="%{authLicence('1_1_7')}">
			<dd><a href="${ctx}/dictionary/dictionarytype-list.action" target="mainframe">数据字典配置</a></dd>
			</s:if>		 
			<dd><a href="${ctx}/system/admin-input.action?orig=editSelf" target="mainframe">修改个人信息</a></dd>
			<s:if test="%{authLicence('1_1_9')}">
			<dd><a href="${ctx}/user/user-list.action" target="mainframe">用户管理</a> </dd>
			</s:if>
			<s:if test="%{authLicence('1_1_8')}">
				<dd><a href="${ctx}/search/hotkeywordrule-list.action" target="mainframe">关键字规则管理</a></dd>
				<dd><a href="${ctx}/search/keywords-list.action" target="mainframe">关键词词库管理</a></dd>
				<dd><a href="${ctx}/search/hotkeyword-list.action" target="mainframe">热门关键字管理</a></dd>
				<dd ><a href="${ctx}/search/lucene-input.action"  target="mainframe">索引生成</a></dd>
			</s:if>
			
	</dl>
	 
</div>
</div>
</body>
</html>
<script type="text/javascript">

$(function(){
	
	siteList();//查询站点列表
	
//六大功能模块及首页切换
	$(".menushow").find("dd").each(function(index){
		$(this).click(function(){
			$(".menushow dd").removeClass("current");
			$(this).addClass("current");
			$(window.parent.document).find("#leftframe").attr("width","220");	
			$(".leftmenu").show();
			$(".leftmenu dl").hide();
			//$(".leftmenu dl .canremove").children().remove(); 
			if(index!=6) $(".menushow").find("dt").addClass("current");
			var menu_id=$(this).attr("id").replace("li","")-1;
			$(".leftmenu dl:eq("+menu_id+")").show();
			if($(this).attr("id")=="li1")
			{
				window.parent.frames['mainframe'].location='site/site-index.action';
			}
			else if($(this).attr("id")=="li2")
			{
				// 栏目树 
				loadCatetree(true,true,'ztree_cat');
				window.parent.frames['mainframe'].location='main.action';
			}
			else if($(this).attr("id")=="li3")
			{
				//内容树
				loadCatetree(false,true,'ztree_content');
				window.parent.frames['mainframe'].location='main.action';
			}
			else if($(this).attr("id")=="li4")
			{
				window.parent.frames['mainframe'].location='${ctx}/topic/topic-list.action';
			}
			else if($(this).attr("id")=="li5")
			{   secondListClass('li5_dl');
				window.parent.frames['mainframe'].location='${ctx}/theme/theme-list.action';
			}
			else if($(this).attr("id")=="li6")
			{
				window.parent.frames['mainframe'].location='${ctx}/generate/list-site.action';
			}
			else if($(this).attr("id")=="li7")
			{	secondListClass('li7_dl');
				<s:if test="%{authLicenceLike('2_2_4')}">
				window.parent.frames['mainframe'].location='${ctx}/plugins/survey-list.action';
				</s:if>
				<s:else>
				window.parent.frames['mainframe'].location='${ctx}/plugins/vote-list.action';
				</s:else>
			}
			else if($(this).attr("id")=="li8")
			{   secondListClass('li8_dl');
				<s:if test="%{authLicence('1_1_3')}">
				window.parent.frames['mainframe'].location='${ctx}/system/role-list.action';
				</s:if>
				<s:elseif test="%{authLicence('1_1_2')}">
				window.parent.frames['mainframe'].location='${ctx}/system/admin-list.action';
				</s:elseif>
				<s:elseif test="%{authLicence('1_1_1')}">
				window.parent.frames['mainframe'].location='${ctx}/system/config-list.action?configType=sys_User_Config';
				</s:elseif>
				<s:else>
				window.parent.frames['mainframe'].location='${ctx}/system/operlog-list.action';
				</s:else>
			}
			else if($(this).attr("id")=="li10")
			{
				window.parent.frames['mainframe'].location='main.action';
				$(".leftmenu").hide();
				$(window.parent.document).find("#leftframe").attr("width","50");	
			}
		});
	});
	
//左侧菜单展开及收拢
	$(".menushow").find("dt").click(function(){
		if($(".menushow dd:eq(6)").attr("class")!="current")
			{
			if($(this).attr("class")!="current")
			{
				$(this).addClass("current");
				$(window.parent.document).find("#leftframe").attr("width","220");	
				$(".leftmenu").show();
			}
			else
			{
				$(this).removeClass("current");
				$(window.parent.document).find("#leftframe").attr("width","50");
				$(".leftmenu").hide();	
			}
		}
	});
//左侧二级菜单列表样式控制
	$(".leftmenu dd").each(function(index){
		$(this).click(function(){
			$(this).parent().find("dd").removeClass("current");
			$(this).addClass("current");
		});
	});
});

function secondListClass(id){
	$("#"+id).find("dd").removeClass("current");
	if($("#"+id).find("dd").first()){		
		$("#"+id).find("dd").first().addClass("current");
	}
}

        //定义全局变量保留选定站点Id
        var flag;
        //选中的站点突出显示为蓝色背景
        function isOpen(status,id){
    	    flag = id;
    	    siteList();
        }
		//站点列表查询
		function siteList(){
			$("#sitemanager dd").remove();
			$.getJSON("${ctx}/site/site-listsite.action?currenttime="+new Date().getTime(),function(data){
					var htmlStr = "";
					var publishStr ="";
					var siteArray = new Array(data.length);
					for(var i=0;i<data.length;i++){
						siteId = data[i].siteId;
						if(data[i].siteStatus == 1){
							if(flag == siteId){
								siteArray[i]="<dd id='"+data[i].siteId+"' class=\"current\"><a href='${ctx}/site/site-gosite.action?site.siteId="+data[i].siteId+"&site.siteStatus="+data[i].siteStatus+"' target='mainframe' onclick=\"isOpen("+data[i].siteStatus+",'"+data[i].siteId+"')\">"+data[i].siteName+"</a></dd>";
							}else{
							    siteArray[i]="<dd id='"+data[i].siteId+"'><a href='${ctx}/site/site-gosite.action?site.siteId="+data[i].siteId+"&site.siteStatus="+data[i].siteStatus+"' target='mainframe' onclick=\"isOpen("+data[i].siteStatus+",'"+data[i].siteId+"')\">"+data[i].siteName+"</a></dd>";
							}
						}else{
							if(flag == siteId){
								siteArray[i]="<dd id='"+data[i].siteId+"' class=\"current\"><a class='current' href='${ctx}/site/site-gosite.action?site.siteId="+data[i].siteId+"&site.siteStatus="+data[i].siteStatus+"' target='mainframe' onclick=\"isOpen("+data[i].siteStatus+",'"+data[i].siteId+"')\">"+data[i].siteName+"</a></dd>";
							}else{
							    siteArray[i]="<dd id='"+data[i].siteId+"'><a class='current' href='${ctx}/site/site-gosite.action?site.siteId="+data[i].siteId+"&site.siteStatus="+data[i].siteStatus+"' target='mainframe' onclick=\"isOpen("+data[i].siteStatus+",'"+data[i].siteId+"')\">"+data[i].siteName+"</a></dd>";
							}
						}
					}
					htmlStr = siteArray.join("");
					$("#sitemanager").append(htmlStr);
				}); 
		}
		//选中的站点突出显示
			function tuchu(id){
				$("#"+id).css("color","#457d07");
			}
		//取消突出显示
			function butuchu(id){
				$("#"+id).css("color","black");
			}
			//如果站点已经禁用，跳转到启用界面
			function goStart(id){
				$.post("${ctx}/site/start-use.action?site.siteId="+id,function(data){
					siteList(); //刷新站点列表
				});
				
				return '${ctx}/site/site-input.action?site.siteId='+id;
			}
			//禁用站点
			function goDisable(siteid){
				$.post("${ctx}/site/site-disable.action?site.siteId="+siteid,function(data){
					siteList(); //刷新站点列表
				});
				
				return '${ctx}/site/status-but.action?site.siteId='+siteid;
			}
			
			//添加站点
			actionName = "site";
			$("#top_new_btn").click(goNew);
			
			function contentManager(topicId){
				 return "${ctx}/topic/topic-contentmanager.action?topic.topicId="+topicId;
			}
			
</script>
<link href="${ctx}/css/zTreeStyle/zTreeStyle.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${ctx}/js/jquery.ztree.core-3.0.js"></script>
<script type="text/javascript">
  function loadCatetree (type,needUrl,id){	
	$.ajax({
		async:false, 
		url:"${ctx}/site/sitetree.action?t="+new Date().getTime(),
		data:{"type":type,"needurl":needUrl},
		type:"post",
		dataType:"text",
		success:function(ss){
			var setting = {
					data: {
						simpleData: {
							enable: true
						}
					}
				};
			var zNodes = eval('('+ss+')');
			$.fn.zTree.init($("#"+id), setting, zNodes);
			 
		}
	});
} 
function expandTarget(zTreeId,catId){
	var treeObj = $.fn.zTree.getZTreeObj(zTreeId);
	var node = treeObj.getNodeByParam("id",catId, null);
	 
	treeObj.selectNode(node);
    treeObj.expandNode(node, true, false, true);
}
</script>